package main

import (
	"fmt"
	"gopkg.in/yaml.v2"
	"io/ioutil"
)
//db:
//driver: mysql
//host: 120.25.228.7
//port: 3306
//dbname: s005
//username: s005
//password: NzL6HrRbkEBGyKTL
//charset: utf8mb4
//
//redis:
//hostname: 127.0.0.1
//port: 6379
//database: 0
//password:

//profile variables
type conf struct {
	App App `yaml:"app"`
	Db Db `yaml:"db"`
	Redis Redis `yaml:"redis"`
}
type App struct {
	Host string `yaml:"host"`
	Port string `yaml:"port"`
}
type Db struct {
	Driver string `yaml:"driver"`
	Host string `yaml:"host"`
	Port string `yaml:"port"`
	Dbname string `yaml:"dbname"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Charset string `yaml:"charset"`
	Prefix string `yaml:"prefix"`
}
type Redis struct {
	Host string `yaml:"host"`
	Port string `yaml:"port"`
	Database string `yaml:"database"`
	Password string `yaml:"password"`
}
func (c *conf) getConf() *conf {
	yamlFile, err := ioutil.ReadFile("E:/WWW/conf.yml")
	if err != nil {
		fmt.Println(err.Error())
	}
	err = yaml.Unmarshal(yamlFile, c)
	if err != nil {
		fmt.Println(err.Error())
	}
	return c
}
